using System;
using System.Collections.Generic;
using System.Text;
using RapidHDL;

namespace _MicroFabric
{
    public class QuickFabricTable : MicroCoreTable
    {
        public QuickFabricTable()
            : base()
        {

            MicroCoreOp oOp;

            //Define Op Codes
            oOp = AddOp("JMP_EQI");
            oOp.AddBranchInstruction("EQI_READY", "EQI_READY");
            oOp.AddJumpInstruction("EQI_NOT_READY");
            oOp.AddStateInstruction("PC_JUMP", "EQI_READY");
            oOp.AddStateInstruction("NOP", "EQI_NOT_READY");
            oOp.AddStateInstruction("NOP");
            oOp.AddStateInstruction("NOP");

            oOp = AddOp("BEQ");
            oOp.AddBranchInstruction("EQ", "JMP_0_EQ");
            oOp.AddJumpInstruction("JMP_0_DONE");
            oOp.AddStateInstruction("PC_JUMP", "JMP_0_EQ");
            oOp.AddStateInstruction("NOP", "JMP_0_DONE");

            oOp = AddOp("JMP");
            oOp.AddStateInstruction("PC_JUMP");
            oOp.AddStateInstruction("NOP");
            oOp.AddStateInstruction("NOP");
            oOp.AddStateInstruction("NOP");

            oOp = AddOp("PUSH_A");
            oOp.AddStateInstruction("PUSH_A");
            oOp.AddStateInstruction("SP_INC");

            oOp = AddOp("PULL_A");
            oOp.AddStateInstruction("SP_DEC");
            oOp.AddStateInstruction("NOP");
            oOp.AddStateInstruction("NOP");
            oOp.AddStateInstruction("PULL_A");

            oOp = AddOp("PUSH_B");
            oOp.AddStateInstruction("PUSH_B");
            oOp.AddStateInstruction("SP_INC");

            oOp = AddOp("PULL_B");
            oOp.AddStateInstruction("SP_DEC");
            oOp.AddStateInstruction("NOP");
            oOp.AddStateInstruction("NOP");
            oOp.AddStateInstruction("PULL_B");

            oOp = AddOp("PROGRAM");
            oOp.AddStateInstruction("PROGRAM");
            oOp.AddStateInstruction("PROGRAM");
            oOp.AddStateInstruction("PROGRAM");

            AddSimpleOp("NOP");
            AddSimpleOp("LOAD_A_C");
            AddSimpleOp("LOAD_B_C");
            AddSimpleOp("LOAD_A_QI");
            AddSimpleOp("LOAD_QO_A");
            AddSimpleOp("EQI_READ");
            AddSimpleOp("COMP_A_C");
            AddSimpleOp("COMP_A_B");
            AddSimpleOp("ADD_A_C");
            AddSimpleOp("ADD_A_B");
            AddSimpleOp("EQO_POST");
            AddSimpleOp("COMP_QT_C");

        }

        public void AddSimpleOp(string psName)
        {
            MicroCoreOp oOp = AddOp(psName);
            oOp.AddStateInstruction(psName);
        }
    }
}
